import datetime

from pydantic import BaseModel, Field
from typing import Optional, List


class OrderBillModel(BaseModel):
    id: Optional[int] = Field(None, primary_key=True)
    state: Optional[str] = Field(None, comment='状态（未结算，已结算）')
    order_id: Optional[str] = Field(None, comment='单号')
    car_id: Optional[str] = Field(None, comment='车辆编码')
    driver_id: Optional[str] = Field(None, comment='驾驶员编码')
    system_mileage: Optional[Optional[float]] = Field(None, comment='系统里程')
    sheet_mileage: Optional[Optional[float]] = Field(None, comment='仪表里程')
    expenses: Optional[Optional[float]] = Field(None, comment='系统里程费用')
    sheet_expenses: Optional[Optional[float]] = Field(None, comment='仪表里程费用')
    create_time: Optional[datetime.datetime] = Field(None, comment='创建时间')
    create_by: Optional[str] = Field(None, comment='创建人')
    update_time: Optional[datetime.datetime] = Field(None, comment='修改时间')
    update_by: Optional[str] = Field(None, comment='修改人')
    bill_type: Optional[str] = Field(None, comment='结算类型 北斗系统结算 表显里程结算')
    starting_expenses: Optional[float] = Field(None, comment='起步价')
    day_expenses: Optional[float] = Field(None, comment='固定费用')
    suspended_expenses: Optional[float] = Field(None, comment='停延费用')
    sum_expenses: Optional[float] = Field(None, comment='总费用')




class OrderBillModelForQuery(BaseModel):
    order_id: Optional[str] = Field(None, title="单号")
    department_id: Optional[str] = Field(None, title="用车部门id")
    department_name: Optional[str] = Field(None, title="用车部门名称")
    order_create_by: Optional[str] = Field(None, title="申请人名称")
    state: Optional[str] = Field(None, title="状态（未结算，已结算）")
    car_number: Optional[str] = Field(None, title="车牌号")
    car_start_time: Optional[datetime.date] = Field(None, title="出车开始时间")
    car_end_time: Optional[datetime.date] = Field(None, title="出车结束时间")

class OrderBillModelForPage(BaseModel):
    id: Optional[int] = Field(None, title="主键")
    order_id: Optional[str] = Field(None, title="单号")
    id_details: Optional[str] = Field(None, title="详情id")
    department_name: Optional[str] = Field(None, title="用车部门名称")
    car_number: Optional[str] = Field(None, comment='车牌号')
    driver_name: Optional[str] = Field(None, comment='驾驶员姓名')
    use_car_type: Optional[str] = Field(None, title="用车类型")
    system_mileage: Optional[str] = Field(None, title="系统里程")
    sheet_mileage: Optional[str] = Field(None, title="仪表里程")
    dispatch_type: Optional[str] = Field(None, title="调度类型")
    mileage: Optional[str] = Field(None, title="里程")
    expenses: Optional[Optional[float]] = Field(None, comment='费用')
    reality_begin_time: Optional[datetime.datetime] = Field(None, comment='实际出车时间')
    reality_end_time: Optional[datetime.datetime] = Field(None, comment='实际回车时间')
    time: Optional[int] = Field(None, comment='时常')
    state: Optional[str] = Field(None, title="状态（未结算，已结算）")


class OrderBillModelForOperate(BaseModel):
    id: Optional[int] = Field(None, title="主键")
    sheet_mileage: Optional[Optional[float]] = Field(None, comment='仪表里程')
    expenses: Optional[Optional[float]] = Field(None, comment='费用')
    operate: Optional[str] = Field(None, title="结算 作废")

class OrderBillModelForOperateBatch(BaseModel):
    id: Optional[int] = Field(None, title="主键")
    operate: Optional[str] = Field(None, title="结算 作废")


class OrderBillModelForUpdate(BaseModel):
    id: Optional[int] = Field(None, title="主键 用车申请表id")
    sheet_mileage: Optional[float] = Field(None, comment='仪表里程')
    system_mileage: Optional[float] = Field(None, comment='系统里程')



class OrderBillPageObject(OrderBillModelForQuery):
    """
    岗位管理分页查询模型
    """
    page_num: int
    page_size: int


class CrudOrderBillResponse(BaseModel):
    is_success: bool
    message: str
